//管道流 提供一个输出流到输入流的机制，用于文件的复制

var fs = require('fs');
var readStream = fs.createReadStream('input.txt');
var writeStream = fs.createWriteStream('input.副本.txt');
readStream.pipe(writeStream);
console.log('程序执行完毕');

//链式流 ：相当于对管道流的连续操作
//压缩
var zlib = require('zlib');
fs.createReadStream('input.txt')
  .pipe(zlib.createGzip())
  .pipe(fs.createWriteStream('input.txt.gz'));
console.log('文件压缩完成');

//解压
fs.createReadStream('input.txt.gz')
  .pipe(zlib.createGunzip())
  .pipe(fs.createWriteStream('inputZip.txt'));
console.log('文件解压完成');
